var mongoose=require('mongoose');
var Attendance=require('./attendance.js');
mongoose.connect('mongodb://localhost/attendance');

var start=new Date(2017,0,1).getTime(),end=Date.now(),now=start;

var letters=(()=>{
    var list=[],code=97;
    while(code<=122){
        list.push(String.fromCharCode(code));
        code++;
    }
    return list;
})();
//console.log('letters:',letters);
letters=letters.sort(()=>{return Math.random()<0.5?-1:1});

1&&(function iife(){
    now+=1000*3600*Math.random()*3|0;
    if(now>end)return console.log('Finish.'),process.exit(1);
    console.log('now:',new Date(now));

    var mt=Math.random()*23|0;
    var name=letters.slice(mt,mt+3);
    name=name[0].toUpperCase()+name.slice(1).join('');
    new Attendance({
        name:name,
        time:new Date(now)
    }).save((err,ret)=>{
        if(err)throw err;
        iife();
    });
})();